/*-----------------------------------------------------------------------------
*      RL-ARM - FlashFS
******-----------------------------------------------------------------------------
*      Name:    RETARGET.C
*      Purpose: Retarget low level functions
*      Rev.:    V4.20
******-----------------------------------------------------------------------------
*      This code is part of the RealView Run-Time Library.
*      Copyright (c) 2004-2011 KEIL - An ARM Company. All rights reserved.
*----------------------------------------------------------------------------*/

#include <stdio.h>
#include <string.h>
#include <rt_sys.h>

#pragma import(__use_no_semihosting_swi)

/* The following macro definitions may be used to translate this file:

   STDIO - use standard Input/Output device
          (default is NOT used)
 */


/* Standard IO device handles. */
#define STDIN   0x8001
#define STDOUT  0x8002
#define STDERR  0x8003

/* Standard IO device name defines. */
const char __stdin_name[]  = "STDIN";
const char __stdout_name[] = "STDOUT";
const char __stderr_name[] = "STDERR";

struct __FILE { int handle; /* Add whatever you need here */ };

#define STDIO
#ifdef STDIO
/*-----------------------------------------------------------------------------
   Write character to Serial Port
*----------------------------------------------------------------------------*/
extern void putch(char ch);

int sendchar(int c)
{
    putch(c);

    return 0;
}

int fputc(int ch, FILE *f)
{
    putch(ch);

    return 0;
}

/*-----------------------------------------------------------------------------
   Read character from Serial Port
*----------------------------------------------------------------------------*/
extern char getch(void);
int getkey(void)
{
    return getch();
}

#endif

/*--------------------------- _ttywrch ---------------------------------------*/

void _ttywrch(int ch)
{
}

/*--------------------------- ferror ---------------------------------------*/
int ferror(FILE *f)
{
    return EOF;
}

/*--------------------------- _sys_open --------------------------------------*/

FILEHANDLE _sys_open(const char *name, int openmode)
{
    return openmode;
}

/*--------------------------- _sys_close -------------------------------------*/

int _sys_close(FILEHANDLE fh)
{
    return 0;
}

/*--------------------------- _sys_write -------------------------------------*/

int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned int len, int mode)
{
    return 0;
}

/*--------------------------- _sys_read --------------------------------------*/

int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned int len, int mode)
{
    return 0;
}

/*--------------------------- _sys_istty -------------------------------------*/

int _sys_istty(FILEHANDLE fh)
{
    return 0;
}

/*--------------------------- _sys_seek --------------------------------------*/

int _sys_seek(FILEHANDLE fh, long pos)
{
    return 0;
}

/*--------------------------- _sys_ensure ------------------------------------*/

int _sys_ensure(FILEHANDLE fh)
{
    return 0;
}

/*--------------------------- _sys_flen --------------------------------------*/

long _sys_flen(FILEHANDLE fh)
{
    return 0;
}

/*--------------------------- _sys_tmpnam ------------------------------------*/

int _sys_tmpnam(char *name, int sig, unsigned maxlen)
{
    return 1;
}

/*--------------------------- _sys_command_string ----------------------------*/

char *_sys_command_string(char *cmd, int len)
{
    return cmd;
}

/*--------------------------- _sys_exit --------------------------------------*/

void _sys_exit(int return_code)
{
    /* Endless loop. */
    while (1)
    {
        ;
    }
}

/*-----------------------------------------------------------------------------
* end of file
*----------------------------------------------------------------------------*/
